<template>
    <view class="container">
      <!-- 注册表单区域 -->
      <view class="form-card">
        <!-- 昵称输入框 -->
        <view class="form-item">
          <text class="label">昵称</text>
          <input 
            class="input" 
            v-model="form.nickname" 
            placeholder="请输入昵称" 
          />
        </view>
  
        <!-- 手机号输入框 -->
        <view class="form-item">
          <text class="label">手机号</text>
          <input 
            class="input" 
            v-model="form.phone" 
            placeholder="请输入手机号" 
            type="number"
          />
        </view>
  
        <!-- 行业领域输入框 -->
        <view class="form-item">
          <text class="label">行业领域</text>
          <input 
            class="input" 
            v-model="form.industry" 
            placeholder="请输入行业领域" 
          />
        </view>
        <view class="form-item">
          <text class="label">所在地区</text>
          <input 
            class="input" 
            v-model="form.region" 
            placeholder="请输入地区" 
          />
        </view>
  
        <!-- 提交按钮 -->
        <button class="submit-btn" @click="onSubmit">提交注册</button>
      </view>
    </view>
  </template>
  
  <script>
  import { editMember } from '@/api/member'

  export default {
    data() {
      return {
        form: {
          nickname: '',
          phone: '',
          industry: '',
          region:''
        }
      }
    },
    methods: {
      // 提交注册
      onSubmit() {
        if (!this.form.nickname) {
          uni.showToast({ title: '请输入昵称', icon: 'none' })
          return
        }
        if (!this.form.phone) {
          uni.showToast({ title: '请输入手机号', icon: 'none' })
          return
        }
        if (!this.form.industry) {
          uni.showToast({ title: '请输入行业领域', icon: 'none' })
          return
        }
        // 调用注册接口
        // console.log('提交注册信息:', this.form)
        const param = {
          username: this.form.nickname,
          phone: this.form.phone,
          industry: this.form.industry,
          region:this.form.region
        }
        editMember(param).then(res=>{
          if(res.code=='1'){
            // console.log("res==",res)
            uni.showToast({ title: '注册成功', icon: 'success' })
            uni.switchTab({
                url: `/pages/mine/mine`
            })
          }
        }).catch(err=>{
            // console.log("err==",err)
          uni.showToast({ title: '注册失败', icon: 'none' })
        })
      }
    }
  }
  </script>
  
  <style>
  .container {
    background: #f5f5f5;
    min-height: 100vh;
    padding: 20px;
  }
  
  .form-card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
  }
  
  .form-item {
    margin-bottom: 20px;
  }
  
  .label {
    font-size: 14px;
    color: #333;
    margin-bottom: 8px;
    display: block;
  }
  
  .input {
    height: 40px;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 0 10px;
    font-size: 14px;
  }
  
  .submit-btn {
    background: #007aff;
    color: #fff;
    border-radius: 4px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    margin-top: 20px;
  }
  </style>